package app.auto.designer.memcache;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import app.auto.designer.tool.SerialUtil;

/**
 * Created by Administrator on 2017/10/26.
 */
public class GlobalCache {
    private static GlobalCache instance = new GlobalCache();

    public static GlobalCache getInstance() {
        return instance;
    }

    public List<String> getEditedLayouts() {
        List<String> list = (List<String>) SerialUtil.getObject("editedlayout");
        if (list == null) {
            setEditedLayouts(new ArrayList<String>());
        }
        list = (List<String>) SerialUtil.getObject("editedlayout");
        return list==null?new ArrayList():list;
    }

    public void setEditedLayouts(List<String> editedLayouts) {
        SerialUtil.saveObject("editedlayout", (Serializable) editedLayouts);
    }

    public String getEditLayoutTag() {
        return "[Edited]";
    }

    public void addEditLayout(Object o, boolean addremove) {
        if (addremove) {
            List<String> set = getEditedLayouts();
            set.add(o.toString());
            setEditedLayouts(set);
        } else {
            List<String> set = getEditedLayouts();
            set.remove(o.toString());
            setEditedLayouts(set);
        }
    }

}
